package moni.anyou.com.view.view.my;

import android.Manifest;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationManager;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import com.amap.api.location.AMapLocation;
import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.CameraUpdateFactory;
import com.amap.api.maps2d.MapView;
import com.amap.api.maps2d.model.BitmapDescriptor;
import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.maps2d.model.LatLngBounds;
import com.amap.api.maps2d.model.Marker;
import com.amap.api.maps2d.model.MarkerOptions;
import com.google.gson.Gson;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import com.readystatesoftware.systembartint.SystemBarTintManager;
import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.tencent.imsdk.TIMCallBack;
import com.tencent.imsdk.TIMConversationType;
import com.tencent.imsdk.TIMImage;
import com.tencent.imsdk.TIMImageElem;
import com.tencent.imsdk.TIMImageType;
import com.tencent.imsdk.TIMLogLevel;
import com.tencent.imsdk.TIMMessage;
import com.tencent.imsdk.TIMMessageStatus;
import com.tencent.imsdk.ext.message.TIMMessageDraft;
import com.tencent.imsdk.ext.message.TIMMessageLocator;
import com.tencent.qcloud.presentation.presenter.ChatPresenter;
import com.tencent.qcloud.presentation.viewfeatures.ChatView;
import com.tencent.qcloud.timchat.model.CustomMessage;
import com.tencent.qcloud.timchat.model.FileMessage;
import com.tencent.qcloud.timchat.model.ImageMessage;
import com.tencent.qcloud.timchat.model.Message;
import com.tencent.qcloud.timchat.model.MessageFactory;
import com.tencent.qcloud.timchat.model.TextMessage;
import com.tencent.qcloud.timchat.model.UGCMessage;
import com.tencent.qcloud.timchat.ui.ChatActivity;
import com.tencent.qcloud.timchat.ui.ImagePreviewActivity;
import com.tencent.qcloud.timchat.utils.FileUtil;
import com.tencent.qcloud.timchat.utils.MediaUtil;
import com.tencent.qcloud.ui.TemplateTitle;
import com.yancy.gallerypick.config.GalleryPick;
import com.yancy.gallerypick.inter.IHandlerCallBack;
//import com.tencent.qcloud.tlslibrary.service.TLSService;
//import com.tencent.qcloud.tlslibrary.service.TlsBusiness;

import org.json.JSONObject;
import org.kymjs.aframe.http.KJHttp;
import org.kymjs.aframe.http.KJStringParams;
import org.kymjs.aframe.http.StringCallBack;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import me.lxz.photopicker.camera.Mode;
import me.lxz.photopicker.camera.PictureSelector;
import moni.anyou.com.view.R;
import moni.anyou.com.view.amap.LocationSendHelper;
import moni.anyou.com.view.amap.LocationService;
import moni.anyou.com.view.amap.MapViewHelper;
import moni.anyou.com.view.amap.cluster.Cluster;
import moni.anyou.com.view.amap.cluster.ClusterClickListener;
import moni.anyou.com.view.amap.cluster.ClusterOverlay;
import moni.anyou.com.view.amap.cluster.ClusterRender;
import moni.anyou.com.view.amap.cluster.demo.RegionItem;
import moni.anyou.com.view.bean.BaseUserInfo;
import moni.anyou.com.view.bean.InitTripDataBean;
import moni.anyou.com.view.bean.JingDianBean;
import moni.anyou.com.view.bean.StartLocationBean;
import moni.anyou.com.view.bean.contacts.StartTripBean;
import moni.anyou.com.view.bean.request.ReqHomeBean;
import moni.anyou.com.view.bean.response.base.ResTeamBean;
import moni.anyou.com.view.config.SysConfig;
//import moni.anyou.com.view.tim.TimHelper;
import moni.anyou.com.view.tim.TimMessageHelper;
import moni.anyou.com.view.utils.BaseAppAdapter;
import moni.anyou.com.view.utils.KJHttpBuild;
//import moni.anyou.com.view.view.ChatGroupLiveRoomActivity;
import moni.anyou.com.view.view.ConfirmChatDialogActivity;
import moni.anyou.com.view.view.ConfirmDialog;

import moni.anyou.com.view.view.LogOut;
//import moni.anyou.com.view.view.VideoChatViewActivity;
//import moni.anyou.com.view.view.VoiceChatViewActivity;
import moni.anyou.com.view.view.my.invitefamily.InviteFriendActivity;
import moni.anyou.com.view.view.photo.local.ConfigHelper;
import moni.anyou.com.view.widget.pikerview.view.RelationSeletor;
import moni.anyou.com.view.widget.utils.imageload.ImageLoadUtil;

import static moni.anyou.com.view.widget.utils.imageload.ImageLoadUtil.getInstance;
//import tencent.tls.platform.TLSErrInfo;
//import tencent.tls.platform.TLSPwdLoginListener;
//import tencent.tls.platform.TLSUserInfo;
//import tencent.tls.platform.TLSErrInfo;
//import tencent.tls.platform.TLSPwdLoginListener;
//import tencent.tls.platform.TLSUserInfo;


public class RouteTeamActivity extends AppCompatActivity implements
      /**高德地图*/ClusterRender, AMap.OnMapLoadedListener, ClusterClickListener
      /**tim*/,ChatView {


    private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
    private static final int IMAGE_STORE = 200;
    private static final int FILE_CODE = 300;
    private static final int IMAGE_PREVIEW = 400;
    private static final int VIDEO_RECORD = 500;
    private static final int PERMISSIONS_REQUEST_READ_CONTACTS = 900;


    @BindView(R.id.map_view)
    MapView mapView;
    @BindView(R.id.tv_longitude)
    TextView tvLongitude;
    @BindView(R.id.label_longitude)
    TextView labelLongitude;
    @BindView(R.id.tv_latitude)
    TextView tvLatitude;
    @BindView(R.id.label_latitude)
    TextView labelLatitude;
    @BindView(R.id.tv_altitude)
    TextView tvAltitude;
    @BindView(R.id.label_altitude)
    TextView labelAltitude;
    @BindView(R.id.tv_positional)
    TextView tvPositional;
    @BindView(R.id.label_positional)
    TextView labelPositional;
    @BindView(R.id.tv_have_gone)
    TextView tvHaveGone;
    @BindView(R.id.label_have_gone)
    TextView labelHaveGone;
    @BindView(R.id.tv_not_going)
    TextView tvNotGoing;
    @BindView(R.id.label_not_going)
    TextView labelNotGoing;
    @BindView(R.id.tv_speed)
    TextView tvSpeed;
    @BindView(R.id.label_speed)
    TextView labelSpeed;
    @BindView(R.id.menu_top)
    LinearLayout menuTop;
    @BindView(R.id.ll_qidong)
    LinearLayout llQidong;
    @BindView(R.id.ll_luxian)
    LinearLayout llLuxian;
    @BindView(R.id.ll_guihua)
    LinearLayout llGuihua;
    @BindView(R.id.ll_jingdian)
    LinearLayout llJingdian;
    @BindView(R.id.ll_3D)
    LinearLayout ll3D;
    @BindView(R.id.ll_tuandui)
    LinearLayout llTuandui;
    @BindView(R.id.ll_liaotianguanbi)
    LinearLayout llLiaotianguanbi;
    @BindView(R.id.menu_right)
    LinearLayout menuRight;
    @BindView(R.id.lv_message)
    ListView lv_message;
    @BindView(R.id.gv_team)
    GridView gvTeam;
    @BindView(R.id.ll_bottom)
    LinearLayout llBottom;
    @BindView(R.id.ll_team)
    LinearLayout llTeam;
    @BindView((R.id.ll_message))
    LinearLayout llMessage;
    @BindView(R.id.ll_message_bottom_bg)
    LinearLayout llMessageBottomBg;
    @BindView(R.id.ll_transfer)
    LinearLayout llTransfer;
    @BindView(R.id.context_layout)
    RelativeLayout context_layout;



    @BindView(R.id.et_input)
    EditText etInput;



    /**是否显示团队*/
    boolean isShowStart=false;
    boolean isShowTeam=false;
    boolean isShowRouteLine=false;
    boolean isShowMessage=false;
    boolean isShowJingDian=false;


    private InitTripDataBean tripData;
    /**景点*/
    private JingDianBean jingDianData;
    private AMap mAMap;
    private String teamId = "0";


    private int clusterRadius = 100;

    private Map<Integer, Drawable> mBackDrawAbles = new HashMap<Integer, Drawable>();

    private ClusterOverlay mClusterOverlay;
    private String TAG="mytim";
    private ChatPresenter presenter;
    private List<Message> messageList = new ArrayList<>();
    private Uri fileUri;
    private List<ResTeamBean.TeamBean> teamList;
    private ArrayList mStringrTeam = new ArrayList<>();
    private RelationSeletor mTeamSeletor;
    private HashMap memberList = new HashMap();
    @Override
    protected void onPostResume() {
        super.onPostResume();
        //        //接口测试
//        sendLocation();
//
//        //景点获取
//        getScenicSpot("1");

        //30 行程界面获取初始信息接口
        initTripInfo();

        init();




    }


    @OnClick({R.id.ll_qidong, R.id.ll_luxian, R.id.ll_guihua, R.id.ll_jingdian, R.id.ll_3D, R.id.ll_tuandui, R.id.ll_liaotianguanbi, R.id.iv_image_select,R.id.ll_transfer,R.id.ll_group_zhibo})
    public void onViewClicked(View view) {
        if(tripData==null)
        {
            Toast.makeText(this,"未获取到服务器数据",Toast.LENGTH_LONG).show();
            return;
        }
        try {
            switch (view.getId()) {
                case R.id.ll_qidong:
                    isShowStart=!isShowStart;
                    new KJHttpBuild().setRequestBean(ReqHomeBean.create("16").keyValue("teamid",tripData.list.get(0).teamInfo.get(0).teamID))
                            .build(new KJHttpBuild.Listen<StartTripBean>() {

                                @Override
                                public void onSuccessData(String data, StartTripBean jsonObj) {
                                    initTripInfo();
                                }

                                @Override
                                public void onFailure(Throwable t, int errorNo, String strMsg) {
                                }
                            });
                    break;
                case R.id.ll_luxian:
                    isShowRouteLine=!isShowRouteLine;
                    if(isShowRouteLine) {
                        llLuxian.setBackgroundResource(R.drawable.juxing);
                        mapViewHelper.drawLocationUI(tripData);
                    }else
                    {
                        llLuxian.setBackgroundResource(R.drawable.juxing_gray);
                        mapViewHelper.clearLocationUI();
                    }
                    break;
                case R.id.ll_guihua:
                    llGuihua.setBackgroundResource(R.drawable.juxing);
                    final ConfirmDialog dialog=new ConfirmDialog(this);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            llGuihua.setBackgroundResource(R.drawable.juxing_gray);
                        }
                    });
                    dialog.setContent(tripData.list.get(0).teamInfo.get(0).scheduling);
                    dialog.setCheckText("确定");
                    dialog.setCheckClick(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            dialog.dismiss();
                        }
                    });
                    break;
                case R.id.ll_jingdian:

                    isShowJingDian=!isShowJingDian;
                    if(isShowJingDian) {
                        mapViewHelper.showJingDian(tripData);
                        llJingdian.setBackgroundResource(R.drawable.juxing);
                    }else{
                        llJingdian.setBackgroundResource(R.drawable.juxing_gray);
                        mapViewHelper.clearJingDian();
                    }

                    break;
                case R.id.ll_3D:
                    if(mClusterOverlay!=null)
                    {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                mClusterOverlay.onDestroy();
                                mClusterOverlay=null;
                            }
                        });
                    }

                    if(mapView.getMap().getMapType()==AMap.MAP_TYPE_NORMAL)
                    {
                        ll3D.setBackgroundResource(R.drawable.juxing);
                        mapView.getMap().setMapType(AMap.MAP_TYPE_SATELLITE);
                    }else {
                        ll3D.setBackgroundResource(R.drawable.juxing_gray);
                        mapView.getMap().setMapType(AMap.MAP_TYPE_NORMAL);
                    }




                    break;
                case R.id.ll_tuandui:
                    isShowTeam=!isShowTeam;
                    if(isShowTeam)
                    {
                        llMessageBottomBg.setVisibility(View.GONE);
                        llTuandui.setBackgroundResource(R.drawable.juxing);
                        llTeam.setVisibility(View.VISIBLE);
                        mapViewHelper.drawTuandui(tripData);
                        showHeadIcon(true);
                    }else
                    {

                        llTuandui.setBackgroundResource(R.drawable.juxing_gray);
                        llTeam.setVisibility(View.GONE);
                        hideHeadIcon();
                        if(isShowMessage==false&&isShowTeam==false)
                        {
                            llMessageBottomBg.setVisibility(View.GONE);
                        }else {
                            llMessageBottomBg.setVisibility(View.VISIBLE);
                        }

                    }

                    break;
                case R.id.ll_liaotianguanbi:
                    isShowMessage=!isShowMessage;
                    if(isShowMessage)
                    {
                        llLiaotianguanbi.setBackgroundResource(R.drawable.juxing);
                        llMessage.setVisibility(View.VISIBLE);
                    }else
                    {
                        llLiaotianguanbi.setBackgroundResource(R.drawable.juxing_gray);
                        llMessage.setVisibility(View.GONE);
                        if(isShowMessage==false&&isShowTeam==false)
                        {
                            llMessageBottomBg.setVisibility(View.GONE);
                        }else {
                            llMessageBottomBg.setVisibility(View.VISIBLE);
                        }

                    }
                    break;
                case R.id.iv_image_select:
                   sendImage();
                   //sendPhoto();
                    break;
                case R.id.ll_transfer:
                    getMyTeamData();
                    break;
                case R.id.ll_group_zhibo:
                    //领队
//                    InitTripDataBean.Data.TeamMemberList teamMember=null;


                    for(InitTripDataBean.Data.TeamMemberList item:tripData.list.get(0).teamMemberList){

                        Log.d("test",item.nick+" "+item.toString());
                      if(item.isLeader.equals("1"))
                      {
//                          Toast.makeText(this,"click33",Toast.LENGTH_LONG).show();
//                          ChatGroupLiveRoomActivity.joinChatGroupLiveRoom(this,item.userID,tripData.list.get(0).teamInfo.get(0).txGroupID,memberList);
                          break;
                      }
                    }

                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    private MapViewHelper mapViewHelper;
    private LocationService locationService;


    private BaseAppAdapter<InitTripDataBean.Data.TeamMemberList> userAdapter;
    private BaseAppAdapter<Message> msgAdapter;

    public String doubleFormat(double d) {
        double value = new BigDecimal(d).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        return String.valueOf(value);
    }

    /**
     * 位置监听
     */
    LocationService.LocationListen locationListen = new LocationService.LocationListen() {

        AMapLocation lastAMapLocation;
        @Override
        public void onListen(final AMapLocation location, final String result) {
            if(location==null)return;

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if(tripData!=null) {
                            if (lastAMapLocation != null) {
                                try {

                                    String[] haveWay = LocationSendHelper.getHaveGone(location, tripData);
                                    String haveWayValue = haveWay[0];
                                    String notGoingValue = haveWay[1];
//                                  String speed = doubleFormat(LocationSendHelper.getDistance(
//                                            location.getLatitude(), location.getLongitude(), lastAMapLocation.getLatitude(), lastAMapLocation.getLongitude()));
                                    //计算获取
                                    tvHaveGone.setText(haveWayValue);
                                    tvNotGoing.setText(notGoingValue);

                                    tvSpeed.setText(doubleFormat(location.getSpeed()));



                                    String icon= null;
                                    try {
                                        BaseUserInfo baseInfo = new Gson().fromJson(SysConfig.userInfoJson.toString(), BaseUserInfo.class);
//                                        icon = SysConfig.PicUrl+baseInfo.icon;
                                        icon = baseInfo.icon;
                                    } catch (Exception e) {
                                        e.printStackTrace();
//                                        icon="http://image.baidu.com/search/detail?ct=503316480&z=undefined&tn=baiduimagedetail&ipn=d&word=%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87&step_word=&ie=utf-8&in=&cl=2&lm=-1&st=undefined&hd=undefined&latest=undefined&copyright=undefined&cs=1727984147,1302708663&os=1436976496,4034396158&simid=3484629463,187165319&pn=1&rn=1&di=1540&ln=1567&fr=&fmq=1553398867919_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&is=0,0&istype=0&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=0&objurl=http%3A%2F%2Fstock.gucheng.com%2FUploadFiles_7844%2F201603%2F2016031621114839.jpg&rpstart=0&rpnum=0&adpicid=0&force=undefined";

                                    }
//

//                                        icon="http://image.baidu.com/search/detail?ct=503316480&z=undefined&tn=baiduimagedetail&ipn=d&word=%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87&step_word=&ie=utf-8&in=&cl=2&lm=-1&st=undefined&hd=undefined&latest=undefined&copyright=undefined&cs=1727984147,1302708663&os=1436976496,4034396158&simid=3484629463,187165319&pn=1&rn=1&di=1540&ln=1567&fr=&fmq=1553398867919_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&is=0,0&istype=0&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=0&objurl=http%3A%2F%2Fstock.gucheng.com%2FUploadFiles_7844%2F201603%2F2016031621114839.jpg&rpstart=0&rpnum=0&adpicid=0&force=undefined";


                                    LocationSendHelper.sendLocation(RouteTeamActivity.this,location,
                                            tripData.list.get(0).teamInfo.get(0).teamID,
                                                   icon,
                                            haveWayValue, notGoingValue,doubleFormat(location.getSpeed()));


//                                    测试 定位一次
//                                    locationService.stopLocation();
                                } catch (Exception e) {
                                    e.printStackTrace();
//                                    StringBuffer sb=new StringBuffer();
//                                    for(StackTraceElement el:e.getStackTrace()){
//                                        sb.append(el+"\n");
//                                    }
//
//
//                                    Toast.makeText(getBaseContext(), sb.toString(), Toast.LENGTH_LONG).show();
//                                    throw  new RuntimeException(e);
                                }
                            }

                            tvLongitude.setText(doubleFormat(location.getLongitude()));
                            tvLatitude.setText(doubleFormat(location.getLatitude()));
                            tvAltitude.setText(doubleFormat(location.getAltitude()));
                            tvPositional.setText(doubleFormat(location.getAccuracy()) + "m");


                        }
                        //Toast.makeText(RouteTeamActivity.this,result,Toast.LENGTH_LONG).show();
                    } catch (Exception e) {
                        e.printStackTrace();

//                        Toast.makeText(RouteTeamActivity.this,"loc2->"+e.toString(),Toast.LENGTH_LONG).show();
                    }

                    lastAMapLocation = location;


                }
            });
        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initState();
        initWindow();
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_route_team);
        ButterKnife.bind(this);

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).imageDownloader(
                new BaseImageDownloader(this, 60 * 1000, 60 * 1000)) // connectTimeout超时时间
                .build();


        ImageLoader.getInstance().init(config);

        mapViewHelper = new MapViewHelper(mapView);
        initLocationService();
        initAdapter();
        init();

        mapView.onCreate(savedInstanceState);
        mAMap=mapView.getMap();

        menuTop.setVisibility(View.INVISIBLE);
        llTeam.setVisibility(View.GONE);

        ll3D.setBackgroundResource(R.drawable.juxing_gray);
        llTransfer.setBackgroundResource(R.drawable.juxing_gray);
        llLuxian.setBackgroundResource(R.drawable.juxing_gray);
        llTuandui.setBackgroundResource(R.drawable.juxing_gray);
        llGuihua.setBackgroundResource(R.drawable.juxing_gray);
        llQidong.setBackgroundResource(R.drawable.juxing_gray);
        llLiaotianguanbi.setBackgroundResource(R.drawable.juxing_gray);
        llMessageBottomBg.setVisibility(View.GONE);
        llJingdian.setBackgroundResource(R.drawable.juxing_gray);



//        TLSService tlsService = TLSService.getInstance();
        String userSig=SysConfig.userSig;
        System.out.println("userSig222222------------"+userSig);
        String id=SysConfig.uid;
        SharedPreferences pref = getSharedPreferences("data", MODE_PRIVATE);
        int loglvl = pref.getInt("loglvl", TIMLogLevel.DEBUG.ordinal());
        System.out.println(" loglvl------------"+ loglvl);
//        //初始化IMSDK
//        InitBusiness.start(getApplicationContext(),loglvl);
//        //初始化TLS
//        TlsBusiness.init(getApplicationContext());




        /**默认初始化位置*/
        Location location=initLocationInMap();
        if(location!=null)
        {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            builder.include(new LatLng(location.getLatitude(),location.getLongitude()));
            LatLngBounds latLngBounds = builder.build();
            mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0)
            );
        }



//        /**针对底部有软菜单的手机*/
//        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) context_layout.getLayoutParams();
//        lp.setMargins(0,0,0,getNavigationBarHeight());

        etInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                //回车键
                if(actionId == EditorInfo.IME_ACTION_SEND){
                    Message message = new TextMessage(etInput.getText());
                    presenter.sendMessage(message.getMessage());
                    etInput.setText("");
                }
                return true;
            }
        });


        setListenerToRootView();
        LogOut.getInstance().addActivity(this);






    }


    /**获取底部状态栏的高度 适配它*/

    public int getNavigationBarHeight() {

        Resources resources = this.getResources();

        int resourceId=resources.getIdentifier("navigation_bar_height","dimen","android");

        int height = resources.getDimensionPixelSize(resourceId);

        Log.v("navigation bar>>>", "height:" + height);

        return height;

    }

    public Location initLocationInMap(){
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        String provider = judgeProvider(locationManager);
        //有位置提供器的情况
        if (provider != null) {
            //为了压制getLastKnownLocation方法的警告
            if (ActivityCompat.checkSelfPermission(getBaseContext(), Manifest.permission.ACCESS_FINE_LOCATION)
                    != PackageManager.PERMISSION_GRANTED
                    && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
                    != PackageManager.PERMISSION_GRANTED) {
                return null;
            }
            return locationManager.getLastKnownLocation(provider);
        }else{
            //不存在位置提供器的情况
            Toast.makeText(this,"不存在位置提供器的情况",Toast.LENGTH_SHORT).show();
        }
        return null;
    }


    private String judgeProvider(LocationManager locationManager) {
        List<String> prodiverlist = locationManager.getProviders(true);
        if(prodiverlist.contains(LocationManager.NETWORK_PROVIDER)){
            return LocationManager.NETWORK_PROVIDER;//网络定位
        }else if(prodiverlist.contains(LocationManager.GPS_PROVIDER)) {
            return LocationManager.GPS_PROVIDER;//GPS定位
        }else{
            Toast.makeText(this,"没有可用的位置提供器",Toast.LENGTH_SHORT).show();
        }
        return null;
    }

   //切换组团
   private void transferTeamData() {
       if (teamList != null) {
           mStringrTeam.clear();
           for (int i = 0; i < teamList.size(); i++) {
               try {

                   mStringrTeam.add(teamList.get(i).teamName);
               } catch (Exception ex) {

               }

           }
           mTeamSeletor = new RelationSeletor(RouteTeamActivity.this, mStringrTeam, new RelationSeletor.ResultHandler() {
               @Override
               public void handle(String teamName) {
                   String currTeamId = "0";
                   //Toast.makeText(RouteTeamActivity.this,""+teamName,Toast.LENGTH_LONG).show();
                   for (int i = 0; i < teamList.size(); i++) {
                       try {

                           if (teamList.get(i).teamName.equals(teamName)) {
                               {
                                   currTeamId = teamList.get(i).teamID;

                                   break;
                               }
                           }
                       } catch (Exception ex) {


                       }
                   }

                   if (!currTeamId.equals("") && !currTeamId.equals(teamId)) {

                       teamId = currTeamId;

                       isShowStart = false;
                       isShowTeam = false;
                       isShowRouteLine = false;
                       isShowMessage = false;
                       isShowJingDian = false;
                       /*显示团队初始化*/
                       llTuandui.setBackgroundResource(R.drawable.juxing_gray);
                       llTeam.setVisibility(View.GONE);
                       hideHeadIcon();
                       llMessageBottomBg.setVisibility(View.GONE);

                       messageList.clear();
                       msgAdapter.notifyDataSetChanged();
                       initTripInfo();
                       init();
                      // Toast.makeText(RouteTeamActivity.this,""+tripData.list.get(0).teamInfo.get(0).txGroupID,Toast.LENGTH_LONG).show();
                       initTimChat(tripData.list.get(0).teamInfo.get(0).txGroupID);
                   }

               }

               @Override
               public void handle(int position) {


               }
           });
           mTeamSeletor.show();
       }
   }



    private void initAdapter() {
        lv_message.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        });
        msgAdapter = new BaseAppAdapter<Message>(lv_message, R.layout.listview_route_team_message, messageList) {

            public int[] colors = {
                    R.color.team_route_text_1,
                    R.color.team_route_text_2,
                    R.color.team_route_text_3,
                    R.color.team_route_text_4,
                    R.color.team_route_text_5
            };


            @Override
            public View getViewIndex(Message data, int position, View convertView, ViewGroup parent) {
                TextView tv_name = (TextView) convertView.findViewById(R.id.tv_name);
                TextView tv_message = (TextView) convertView.findViewById(R.id.tv_message);

                ProgressBar progress = convertView.findViewById(R.id.sending);
                final ImageView iv_img = (ImageView) convertView.findViewById(R.id.iv_img);
                iv_img.setVisibility(View.VISIBLE);
                TIMMessage message = data.getMessage();
                String name = "";
                if (message.getSenderGroupMemberProfile() != null)
                    name = message.getSenderGroupMemberProfile().getNameCard();
                if (name.equals("") && message.getSenderProfile() != null)
                    name = message.getSenderProfile().getNickName();
                if (name.equals("")) name = message.getSender();


                /***将tim_id 转成用户名*/
                if (memberList.get(name.trim()) != null) {
                    tv_name.setText(((InitTripDataBean.Data.TeamMemberList)memberList.get(name.trim())).nick);
                    //Log.v("team member>>>", tripData.list.get(0).teamMemberList.toString());
                    //Log.v("team member name>>>", name);

                    /*
                    for(InitTripDataBean.Data.TeamMemberList teamMember:tripData.list.get(0).teamMemberList)
                    {
                        if(name.equals(teamMember.userID))
                        {
                            Log.v("team member userID>>>",teamMember.userID );


                        }
                        else
                        {
                            tv_name.setText(tripData.list.get(0).teamInfo.get(0).nick);
                        }

                    }
                    */

                } else {
                    tv_name.setText(name + ":");
                }
                tv_message.setText(TimMessageHelper.showMessage(data));


                if(data instanceof TextMessage) {
                    iv_img.setVisibility(View.GONE);
                    tv_name.setTextColor(getResources().getColor(R.color.white));
                    //tv_name.setTextColor(getResources().getColor(colors[position % colors.length]));
                }else if(data instanceof ImageMessage){

                    try {
                        iv_img.setVisibility(View.VISIBLE);
                        TIMImageElem e = (TIMImageElem) message.getElement(0);
                        final String localPic = e.getPath();
                        switch (message.status()){
                            case Sending:

    //                            ImageView imageView = new ImageView(TimApplication.getTimAppcation());
                                iv_img.setImageBitmap(getThumb(e.getPath()));

                                break;
                            case SendSucc:
                                for(final TIMImage image : e.getImageList()) {
                                    if (image.getType() == TIMImageType.Thumb){
                                        final String uuid = image.getUuid();
                                        if (FileUtil.isCacheFileExist(uuid)){
                                            Bitmap bitmap = BitmapFactory.decodeFile(FileUtil.getCacheFilePath(uuid));
                                            iv_img.setImageBitmap(bitmap);
                                            iv_img.setOnClickListener(new View.OnClickListener() {
                                                @Override
                                                public void onClick(View v) {
                                                    imageBrower(uuid);
                                                    //Toast.makeText(RouteTeamActivity.this,"图片被点击"+ FileUtil.getCacheFilePath(uuid),Toast.LENGTH_LONG).show();
                                                }
                                            });
                                        }else{
                                            image.getImage(FileUtil.getCacheFilePath(uuid), new TIMCallBack() {
                                                @Override
                                                public void onError(int code, String desc) {//获取图片失败
                                                    //错误码code和错误描述desc，可用于定位请求失败原因
                                                    //错误码code含义请参见错误码表
                                                    Log.e(TAG, "getImage failed. code: " + code + " errmsg: " + desc);
                                                }

                                                @Override
                                                public void onSuccess() {//成功，参数为图片数据
                                                    final String uuid = image.getUuid();
                                                    Bitmap bitmap = BitmapFactory.decodeFile(FileUtil.getCacheFilePath(uuid));
                                                    iv_img.setImageBitmap(bitmap);
                                                    iv_img.setOnClickListener(new View.OnClickListener() {
                                                        @Override
                                                        public void onClick(View v) {
                                                            imageBrower(uuid);
                                                            //Toast.makeText(RouteTeamActivity.this,"图片被点击"+ FileUtil.getCacheFilePath(uuid),Toast.LENGTH_LONG).show();
                                                        }
                                                    });
                                                }
                                            });
                                        }
                                    }
                                    /*
                                    if (image.getType() == TIMImageType.Original){
                                        final String uuid = image.getUuid();
    //                        setImageEvent(viewHolder, uuid,context);
                                          iv_img.setOnClickListener(new View.OnClickListener() {
                                            @Override
                                            public void onClick(View v) {
                                                imageBrower(uuid,image);
                                                //Toast.makeText(RouteTeamActivity.this,"图片被点击"+ FileUtil.getCacheFilePath(uuid),Toast.LENGTH_LONG).show();
                                            }
                                        });
                                    }
                                    */
                                }
                                break;
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }

                showStatus(message,true,progress);
                return convertView;
            }
        };

        lv_message.setAdapter(msgAdapter);
    }
    private void imageBrower( String urls) {
        Intent intent = new Intent(RouteTeamActivity.this ,ShowImageActivity.class);
        intent.putExtra(ShowImageActivity.EXTRA_IMAGE_URLS, urls);
        intent.putExtra(ShowImageActivity.EXTRA_IMAGE_INDEX, 0);
        startActivity(intent);
    }
    private void initLocationService() {
        locationService = new LocationService();
        locationService.setLocationListen(locationListen);
        locationService.checkRxPermissions(this);
        locationService.showLocationEnabled(this);
    }



    /**
     * 显示消息状态
     *
     */
    public void showStatus(TIMMessage message, Boolean isText, ProgressBar sending){
        switch (message.status()){
            case Sending:
                sending.setVisibility(View.VISIBLE);
                break;
            case SendSucc:
                sending.setVisibility(View.GONE);
                break;
            case SendFail:
                sending.setVisibility(View.GONE);
                break;
        }
    }






    @Override
    protected void onResume() {
        super.onResume();
//        locationService.startLocation();
        initTripInfo();
        init();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        locationService.stopLocation();
        if(presenter!=null) {
            presenter.stop();
        }
        if (locationService != null){
            locationService.stopLocation();
        }
    }


    protected void onPause(){
        super.onPause();
        if(presenter!=null) {
            presenter.readMessages();
        }
        MediaUtil.getInstance().stop();
    }




    public void initTimChat(String identify){

        try {
            if(presenter!=null)
            {
                messageList.clear();
                presenter.stop();

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        presenter = new ChatPresenter(this, identify, TIMConversationType.Group);
        presenter.start();
    }


    @Override
    public void showMessage(TIMMessage message) {
        Log.d(TAG,"showMessage(TIMMessage message)");
        if (message == null) {
            msgAdapter.notifyDataSetChanged();
        } else {
            Message mMessage = MessageFactory.getMessage(message);
            if (mMessage != null) {
                if (mMessage instanceof CustomMessage){
                    CustomMessage.Type messageType = ((CustomMessage) mMessage).getType();
                    switch (messageType){
                        case TYPING:
                            TemplateTitle title = (TemplateTitle) findViewById(R.id.chat_title);
                            title.setTitleText(getString(R.string.chat_typing));
                            break;
                        default:
                            break;
                    }
                }else{
                    if (messageList.size()==0){
                        mMessage.setHasTime(null);
                    }else{
                        mMessage.setHasTime(messageList.get(messageList.size()-1).getMessage());
                    }
                    messageList.add(mMessage);
                    msgAdapter.notifyDataSetChanged();
                }

            }
            lv_message.setSelection(msgAdapter.getCount());
        }

    }

    @Override
    public void showMessage(List<TIMMessage> messages) {

        Log.d("mytim", "public void showMessage(List<TIMMessage> messages) {");

        for (TIMMessage message :messages)
        {
            Log.d("mytim", TimMessageHelper.showTimMessage(message).toString());
        }
        int newMsgNum = 0;
        for (int i = 0; i < messages.size(); ++i){
            Message mMessage = MessageFactory.getMessage(messages.get(i));
            if (mMessage == null || messages.get(i).status() == TIMMessageStatus.HasDeleted) continue;
            if (mMessage instanceof CustomMessage && (((CustomMessage) mMessage).getType() == CustomMessage.Type.TYPING ||
                    ((CustomMessage) mMessage).getType() == CustomMessage.Type.INVALID)) continue;
            ++newMsgNum;
            if (i != messages.size() - 1){
                mMessage.setHasTime(messages.get(i+1));
                messageList.add(0, mMessage);
            }else{
                mMessage.setHasTime(null);
                messageList.add(0, mMessage);
            }
        }
        msgAdapter.notifyDataSetChanged();
        lv_message.setSelection(newMsgNum);

    }

    @Override
    public void showRevokeMessage(TIMMessageLocator timMessageLocator) {

    }

    @Override
    public void clearAllMessage() {

    }

    @Override
    public void onSendMessageSuccess(TIMMessage message) {

    }

    @Override
    public void onSendMessageFail(int code, String desc, TIMMessage message) {

    }

    /**
     * 发送图片消息
     */
    @Override
    public void sendImage() {
        RxPermissions rxPermissions = new RxPermissions(this);
        String[] arr = {
                Manifest.permission.CAMERA,
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.READ_EXTERNAL_STORAGE

        };
        rxPermissions.requestEach(arr).buffer(arr.length)
                .subscribe(new Observer<List<Permission>>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(List<Permission> list) {

                        boolean b=true;
                        for(Permission it :list ){
                            if(it.granted==false){
                                b=false;
                                break;
                            }
                        }
                        if(b)
                        {
//                            try {
//                                Intent intent_album = new Intent("android.intent.action.GET_CONTENT");
//                                intent_album.setType("image/*");
//                                startActivityForResult(intent_album, IMAGE_STORE);
//                            } catch (Exception e) {
//                                e.printStackTrace();
//                            }


                            PictureSelector.create(RouteTeamActivity.this,Mode.AS_WEIXIN_IMGCAPTRUE)
                                    .setMaxFileCount(1)
                                    .setCut(false)
                                    .setListen(
                                            new me.lxz.photopicker.camera.OnPhotoPickFinsh() {
                                                @Override
                                                public void onPhotoPick(List<File> list) {
                                                    if(list==null||list.isEmpty())return;
                                                    File file = list.get(0);
                                                    if (file.exists()){
                                                        final BitmapFactory.Options options = new BitmapFactory.Options();
                                                        options.inJustDecodeBounds = true;
                                                        BitmapFactory.decodeFile(file.getPath(), options);
                                                        if (file.length() == 0 && options.outWidth == 0) {
                                                            Toast.makeText(getBaseContext(), getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
                                                        }else {
                                                            if (file.length() > 1024 * 1024 * 10){
                                                                Toast.makeText(getBaseContext(), getString(R.string.chat_file_too_large),Toast.LENGTH_SHORT).show();
                                                            }else{
                                                                Message message = new ImageMessage(file.getPath(),false);
                                                                presenter.sendMessage(message.getMessage());
                                                            }
                                                        }
                                                    }
                                                }}
                                    ).start();

                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

        /*
        Log.d("mytim","sendImage()");
        Intent intent_album = new Intent("android.intent.action.GET_CONTENT");
        intent_album.setType("image/*");
        startActivityForResult(intent_album, IMAGE_STORE);
        */
    }


    private IHandlerCallBack iHandlerCallBack = new IHandlerCallBack() {
        @Override
        public void onStart() {
            //开启
            //Toast.makeText(RouteTeamActivity.this,""+"开启",Toast.LENGTH_LONG).show();

        }

        @Override
        public void onSuccess(List<String> photoList) {
           // Toast.makeText(RouteTeamActivity.this,""+photoList,Toast.LENGTH_LONG).show();
            try {
                if(photoList!=null&&photoList.size()>=0)
                {
    ;

                    String path = photoList.get(0);
                    File file = new File(path);
                    if (file.exists()){
                        final BitmapFactory.Options options = new BitmapFactory.Options();
                        options.inJustDecodeBounds = true;
                        BitmapFactory.decodeFile(path, options);
                        Message message = new ImageMessage(path,false);
                        presenter.sendMessage(message.getMessage());
    //                    if (file.length() == 0 && options.outWidth == 0) {
    //                        Toast.makeText(this, getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
    //                    }else {
    //                        if (file.length() > 1024 * 1024 * 10){
    //                            Toast.makeText(this, getString(R.string.chat_file_too_large),Toast.LENGTH_SHORT).show();
    //                        }else{

    //                        }
                        }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onFinish() {

        }

        @Override
        public void onError() {

        }
    };
    /**
     * 发送照片消息
     */
    @Override
    public void sendPhoto() {
        RxPermissions rxPermissions = new RxPermissions(this);
        String[] arr = {
                Manifest.permission.CAMERA,
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.READ_EXTERNAL_STORAGE

        };
        rxPermissions.requestEach(arr).buffer(arr.length)
                .subscribe(new Observer<List<Permission>>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(List<Permission> list) {

                        boolean b=true;
                        for(Permission it :list ){
                            if(it.granted==false){
                                b=false;
                                break;
                            }
                        }
                        if(b)
                        {
                            try {
                                GalleryPick.getInstance().setGalleryConfig(ConfigHelper.getInstance().getPhotoConfig(iHandlerCallBack)).open(RouteTeamActivity.this);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

        /*
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            Log.i(TAG, "需要授权 ");
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                Log.i(TAG, "拒绝过了");
                // 提示用户如果想要正常使用，要手动去设置中授权。
                Toast.makeText(this, "请在 设置-应用管理 中开启此应用的储存授权。", Toast.LENGTH_SHORT).show();
            } else {
                Log.i(TAG, "进行授权");
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_READ_CONTACTS);
            }
        } else {
            Log.i(TAG, "不需要授权 ");
            // 进行正常操作



        }
        GalleryPick.getInstance().setGalleryConfig(ConfigHelper.getInstance().getPhotoConfig(iHandlerCallBack)).open(this);
        */
    }

//    Override
//    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
//        if (requestCode == PERMISSIONS_REQUEST_READ_CONTACTS) {
//            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                Log.i(TAG, "同意授权");
//                // 进行正常操作。
//            } else {
//                Log.i(TAG, "拒绝授权");
//            }
//        }
//    }


//        Log.d("mytim","sendPhoto()");
//        Intent intent_photo = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//        if (intent_photo.resolveActivity(getPackageManager()) != null) {
//            File tempFile = FileUtil.getTempFile(FileUtil.FileType.IMG);
//            if (tempFile != null) {
//                fileUri = UriUtils.file2Uri(this,tempFile);
//            }
//            intent_photo.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
//            startActivityForResult(intent_photo, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
//        }
//    }

    @Override
    public void sendText() {
        Message message = new TextMessage(etInput.getText());
        presenter.sendMessage(message.getMessage());
        etInput.setText("");
    }

    @Override
    public void sendText(String str) {
        Message message = new TextMessage(str);
        presenter.sendMessage(message.getMessage());
    }

    @Override
    public void sendFile() {
        Log.d("mytim","sendFile()");
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        startActivityForResult(intent, FILE_CODE);
    }

    @Override
    public void startSendVoice() {

    }

    @Override
    public void endSendVoice() {

    }

    @Override
    public void sendVideo(String fileName) {

    }

    @Override
    public void cancelSendVoice() {

    }

    @Override
    public void sending() {

    }

    @Override
    public void showDraft(TIMMessageDraft draft) {

    }

    @Override
    public void videoAction() {

    }

    @Override
    public void showToast(String msg) {

    }


//    class Message {
//        public String id;
//        public String name;
//        public String msg;
//        public List<String> imgs;
//    }


    /**获取初始化信息*/
    private void initTripInfo() {
        new KJHttpBuild().setRequestBean(ReqHomeBean.cmd("30",teamId))
                .build(new KJHttpBuild.Listen<InitTripDataBean>() {

                    @Override
                    public void onSuccessData(String data, InitTripDataBean jsonObj) {

                        tripData=jsonObj;
                        if(jsonObj.list!=null&&!jsonObj.list.isEmpty())
                        {
                            teamId = jsonObj.list.get(0).teamInfo.get(0).teamID;

                            for(InitTripDataBean.Data.TeamMemberList team:jsonObj.list.get(0).teamMemberList) {
                                ImageLoader.getInstance().loadImage(SysConfig.PicUrl + team.icon,null);
                                memberList.put(team.userID,team);
                            }
                            changeGridView();
                            initTimChat(jsonObj.list.get(0).teamInfo.get(0).txGroupID);

                            userGroupChatRoom();

                        }
                       // else{
                      //      Toast.makeText(RouteTeamActivity.this,"没进来",Toast.LENGTH_LONG).show();
                        //}
                        //这里要改成接口
                        if ("1".equals(tripData.list.get(0).teamInfo.get(0).startFlag))
                        {
                            llQidong.setBackgroundResource(R.drawable.juxing);
                            locationService.startLocation();
                            menuTop.setVisibility(View.VISIBLE);
                        }else
                        {
                            llQidong.setBackgroundResource(R.drawable.juxing_gray);
                            locationService.stopLocation();
                            menuTop.setVisibility(View.INVISIBLE);
                        }
                    }

                    @Override
                    public void onFailure(Throwable t, int errorNo, String strMsg) {

                    }
                });
    }

    /***聊天室*/
    private void userGroupChatRoom(){

        final List<InitTripDataBean.Data.TeamMemberList> list = tripData.list.get(0).teamMemberList;
        List<InitTripDataBean.Data.TeamMemberList> datas = new ArrayList<>();
        datas.addAll(list);
        {
            InitTripDataBean.Data.TeamMemberList addBtn = new InitTripDataBean.Data.TeamMemberList();
            addBtn.actionType=999;
            datas.add(addBtn);
        }

        /**---测试数据---*/
        userAdapter = new BaseAppAdapter<InitTripDataBean.Data.TeamMemberList>(gvTeam, R.layout.gradview_route_team_item, datas) {

            @Override
            public View getViewIndex(InitTripDataBean.Data.TeamMemberList user, int position, View convertView, ViewGroup parent) {
                CircleImageView civ_head = (CircleImageView) convertView.findViewById(R.id.civ_head);
                TextView tv_name = (TextView) convertView.findViewById(R.id.tv_name);
                View tv_msg = (TextView) convertView.findViewById(R.id.tv_msg);
                if (user.icon != null) {
                    getInstance(
                            getBaseContext()).
                            mImageLoader.displayImage(SysConfig.PicUrl+user.icon,
                            civ_head,
                            ImageLoadUtil.getOptions(R.drawable.loading_11,
                                    R.drawable.loading_err_11,
                                    R.drawable.loading_null_11));
                    Log.d("gaodemap","gridview->"+SysConfig.PicUrl+user.icon);
                } else {
                    civ_head.setImageResource(R.drawable.w_1);
                }
                tv_name.setText(user.nick);
                if("1".equals(user.isLeader)){
                    tv_msg.setVisibility(View.VISIBLE);
                }else
                {
                    tv_msg.setVisibility(View.GONE);
                }
                //1是普通成员 2是领队   999是邀请
                switch (user.actionType) {
                    case 1:
                        tv_msg.setVisibility(View.GONE);
                        break;
                    case 2:
                        tv_msg.setVisibility(View.VISIBLE);
                        break;
                    case 999:
                        civ_head.setImageResource(R.drawable.jiaren);
                        tv_msg.setVisibility(View.GONE);
                        tv_name.setText("邀请");
                        break;

                }
                civ_head.setTag(user);
                civ_head.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        InitTripDataBean.Data.TeamMemberList user = (InitTripDataBean.Data.TeamMemberList) v.getTag();
                        if (user.actionType == 999) {
                            Intent i = new Intent();
                            i.putExtra("teamID", teamId);
                            i.setClass(RouteTeamActivity.this, InviteFriendActivity.class);
                            startActivity(i);
                        }else{
                            List<InitTripDataBean.Data.TeamMemberList> arr = tripData.list.get(0).teamMemberList;
                            HashMap<String,String> idsKeyNick=new HashMap<>();
                            for(InitTripDataBean.Data.TeamMemberList item:arr)
                            {
                                idsKeyNick.put(item.userID,item.nick);
                            }

                            BaseUserInfo baseInfo = new Gson().fromJson(SysConfig.userInfoJson.toString(), BaseUserInfo.class);
//                            ChatActivity.navToChat(RouteTeamActivity.this,user.userID,TIMConversationType.C2C);
                            ChatActivity.navToChat(RouteTeamActivity.this,user.userID,SysConfig.uid,TIMConversationType.C2C,idsKeyNick,
                                    SysConfig.PicUrl+user.icon,
                                    SysConfig.PicUrl+baseInfo.icon,getInstance(RouteTeamActivity.this).mImageLoader);
                        }
                    }
                });
                return convertView;
            }
        };
    }






    private void init() {

//        ImageLoader.getInstance().loadImage("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1554523034,2873630108&fm=26&gp=0.jpg",null);

        if (mAMap == null) {
            // 初始化地图
            mAMap = mapView.getMap();
            mAMap.setOnMapLoadedListener(this);
            //点击可以动态添加点
            mAMap.setOnMapClickListener(new AMap.OnMapClickListener() {
                @Override
                public void onMapClick(LatLng latLng) {
//                    double lat = Math.random() + 39.474923;
//                    double lon = Math.random() + 116.027116;
//
//                    LatLng latLng1 = new LatLng(lat, lon);
//                    RegionItem<String> regionItem = new RegionItem<String>(latLng1,
//                            "test");
//                    mClusterOverlay.addRegionItem(regionItem);

                }
            });
        }
    }




    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }



    @Override
    public void onMapLoaded() {



    }


    private void hideHeadIcon() {
        if(mClusterOverlay!=null)
        {
            mClusterOverlay.onDestroy();
        }
    }



    public void showHeadIcon(final boolean isMoveCamera) {


//        if(mClusterOverlay!=null)return;

        //添加测试数据
        new Thread() {

            HashMap<String,Bitmap> bitmapHashMap=new HashMap<>();

            public void run() {

                try {
                    List<RegionItem> items = new ArrayList<RegionItem>();

                    if(LocationSendHelper.lastStartLocationBean==null||LocationSendHelper.lastStartLocationBean.recordList==null)
                    {
                        return;
                    }


                    try {

                        if(isMoveCamera) {
                            StartLocationBean.RecordList bean2 = LocationSendHelper.lastStartLocationBean.recordList.get(0);
                            LatLng latLng2 = new LatLng(Double.valueOf(bean2.latitude), Double.valueOf(bean2.longitude));
                            mapView.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(latLng2, 12));
                        }



                        for (int i = 0,j=LocationSendHelper.lastStartLocationBean.recordList.size(); i < j; i++) {
                            StartLocationBean.RecordList bean = LocationSendHelper.lastStartLocationBean.recordList.get(i);
                            LatLng latLng = new LatLng(Double.valueOf(bean.latitude), Double.valueOf(bean.longitude));

                            RegionItem regionItem = new RegionItem(latLng,
                                    "test" + i);

                            //做一个去重复处理
                            String imgUrl=SysConfig.PicUrl+bean.icon.replaceAll(SysConfig.PicUrl,"");
                            regionItem.setTag(imgUrl);

                            bitmapHashMap.put(imgUrl,ImageLoader.getInstance().loadImageSync(imgUrl));

                            items.add(regionItem);

                            Log.d("gaodemap",SysConfig.PicUrl+bean.icon);

                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }


                    if(mClusterOverlay!=null)
                    {
                        mClusterOverlay.onDestroy();
                    }
//                //随机10000个点
//                for (int i = 0; i < 5; i++) {
//
//                    double lat = Math.random() + 39.474923;
//                    double lon = Math.random() + 116.027116;
//
//                    LatLng latLng = new LatLng(lat, lon);
//                    RegionItem regionItem = new RegionItem(latLng,
//                            "test" + i);
//                    items.add(regionItem);
//
//                }
                    mClusterOverlay = new ClusterOverlay(mapView,mAMap, items,
                            dp2px(getApplicationContext(), clusterRadius),
                            getApplicationContext());
                    mClusterOverlay.setClusterRenderer(RouteTeamActivity.this);
                    mClusterOverlay.setOnClusterClickListener(RouteTeamActivity.this);
                    mClusterOverlay.setDrawMarker(new ClusterOverlay.DrawMarker() {

                        @Override
                        public void draw(MarkerOptions markerOptions, Marker marker, final Cluster cluster) {
                            if(markerOptions!=null)
                            {
    //                           markerOptions.anchor(0.5f, 0.5f)
    //                           .icon(mClusterOverlay.getBitmapDes(cluster.getClusterCount())).position(cluster.getCenterLatLng());
                                if(cluster.getClusterCount()==1) {
                                    CircleImageView view = new CircleImageView(RouteTeamActivity.this);
                                    view.setLayoutParams(new FrameLayout.LayoutParams(120, 120));



                                    if(cluster.getRegionItems()!=null&&!cluster.getRegionItems().isEmpty()) {
                                        try {

                                            Bitmap bitmap = bitmapHashMap.get(cluster.getRegionItems().get(0).getTag().toString());

                                            try {
                                                Log.d("gaodemap","tag:"+(cluster.getRegionItems().get(0).getTag().toString()));
                                                Log.d("gaodemap","bitmap:"+(bitmap==null));

                                            } catch (Exception e) {
                                                e.printStackTrace();
                                            }

                                            if(bitmap==null)
                                            {
                                                view.setImageResource(R.mipmap.ic_launcher);
                                            }else{
                                                view.setImageBitmap(bitmap);
                                            }
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                            view.setImageResource(R.mipmap.ic_launcher);
                                        }

                                    }else {
                                        view.setImageResource(R.mipmap.ic_launcher);
                                    }

                                    BitmapDescriptor icon = BitmapDescriptorFactory.fromView(view);
                                    markerOptions.anchor(0.5f, 0.5f)
                                            .icon(icon)
                                            .position(cluster.getCenterLatLng());
                                }else
                                {

                                    DisplayImageOptions options = new DisplayImageOptions.Builder()
                                            .cacheOnDisk(true)
                                            .cacheInMemory(true)
                                            .build();
                                    List<RegionItem> items=cluster.getRegionItems();
    //                                for(RegionItem item:items) {
    //                                    Bitmap bitmap =ImageLoader.getInstance().loadImageSync(SysConfig.PicUrl);
    //                                    bitmapHashMap.put(SysConfig.PicUrl+item.getTag().toString(),bitmap);
    //                                }

    //                                 bitmap = ImageLoader.getInstance().loadImageSync("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1554523034,2873630108&fm=26&gp=0.jpg", options);


                                    GridView gridView=  new GridView(RouteTeamActivity.this);
                                    gridView.setColumnWidth(30);
                                    gridView.setMinimumWidth(30);
                                    gridView.setHorizontalSpacing(30);
                                    gridView.setNumColumns(4);
                                    gridView.setAdapter(new BaseAdapter(){

                                        @Override
                                        public int getCount() {
                                            return cluster.getClusterCount();
                                        }

                                        @Override
                                        public Object getItem(int position) {
                                            return null;
                                        }

                                        @Override
                                        public long getItemId(int position) {
                                            return 0;
                                        }

                                        @Override
                                        public View getView(int position, View convertView, ViewGroup parent) {
                                            CircleImageView tv = new CircleImageView(RouteTeamActivity.this);
                                            try {
                                                tv.setLayoutParams(new ViewGroup.LayoutParams(120,120));

                                                Bitmap bitmap=bitmapHashMap.get(cluster.getRegionItems().get(position).getTag().toString());
                                                if(bitmap==null)
                                                {
                                                    tv.setImageResource(R.mipmap.ic_launcher);
                                                }else
                                                {
                                                   tv.setImageBitmap(bitmap);
                                                }
                                            } catch (Exception e) {
                                                e.printStackTrace();
                                                tv.setImageResource(R.mipmap.ic_launcher);
                                            }
                                            return tv;
                                        }
                                    });
                                    if(cluster.getClusterCount()<4) {
                                        gridView.setLayoutParams(new FrameLayout.LayoutParams(cluster.getClusterCount() * 120, 120));
                                    }else
                                    {
                                        gridView.setLayoutParams(new FrameLayout.LayoutParams(4 * 120, ((cluster.getClusterCount()/4)+1)*120));
                                    }
                                    BitmapDescriptor icon = BitmapDescriptorFactory.fromView(gridView);
                                    markerOptions.anchor(0.5f, 0.5f)
                                            .icon(icon)
                                            .position(cluster.getCenterLatLng());
                                }
                            }
    //                        if(marker!=null)
    //                        {
    //                            ImageView view=new ImageView(MainActivity.this);
    //                            view.setImageResource(R.mipmap.ic_launcher);
    //                            BitmapDescriptor icon = BitmapDescriptorFactory.fromView(view);
    //                            marker.setPosition(cluster.getCenterLatLng());
    //                            marker.setIcon(icon);
    //                        }
                        }


                    });
                } catch (final Exception e) {
                    e.printStackTrace();

//                    runOnUiThread(new Runnable() {
//                        @Override
//                        public void run() {
//                            Toast.makeText(RouteTeamActivity.this,e.toString(),Toast.LENGTH_LONG).show();
//                        }
//                    });
                }

            }

        }

                .start();
    }


    @Override
    public void onClick(Marker marker, List<RegionItem> RegionItems) {
        if (RegionItems != null) {
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (RegionItem RegionItem : RegionItems) {
                builder.include(RegionItem.getPosition());
            }
            LatLngBounds latLngBounds = builder.build();
            mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0)
            );
        }
    }

    @Override
    public Drawable getDrawAble(int clusterNum) {
        int radius = dp2px(getApplicationContext(), 80);
        if (clusterNum == 1) {
            Drawable bitmapDrawable = mBackDrawAbles.get(1);
            if (bitmapDrawable == null) {
                bitmapDrawable =
                        getApplication().getResources().getDrawable(
                                R.drawable.icon_openmap_mark);
                mBackDrawAbles.put(1, bitmapDrawable);
            }

            return bitmapDrawable;
        } else if (clusterNum < 5) {

            Drawable bitmapDrawable = mBackDrawAbles.get(2);
            if (bitmapDrawable == null) {
                bitmapDrawable = new BitmapDrawable(null, drawCircle(radius,
                        Color.argb(159, 210, 154, 6)));
                mBackDrawAbles.put(2, bitmapDrawable);
            }

            return bitmapDrawable;
        } else if (clusterNum < 10) {
            Drawable bitmapDrawable = mBackDrawAbles.get(3);
            if (bitmapDrawable == null) {
                bitmapDrawable = new BitmapDrawable(null, drawCircle(radius,
                        Color.argb(199, 217, 114, 0)));
                mBackDrawAbles.put(3, bitmapDrawable);
            }

            return bitmapDrawable;
        } else {
            Drawable bitmapDrawable = mBackDrawAbles.get(4);
            if (bitmapDrawable == null) {
                bitmapDrawable = new BitmapDrawable(null, drawCircle(radius,
                        Color.argb(235, 215, 66, 2)));
                mBackDrawAbles.put(4, bitmapDrawable);
            }

            return bitmapDrawable;
        }
    }

    private Bitmap drawCircle(int radius, int color) {

        Bitmap bitmap = Bitmap.createBitmap(radius * 2, radius * 2,
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        RectF rectF = new RectF(0, 0, radius * 2, radius * 2);
        paint.setColor(color);
        canvas.drawArc(rectF, 0, 360, true, paint);
        return bitmap;
    }

    /**
     * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
     */
    public int dp2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        Toast.makeText(this,""+resultCode,Toast.LENGTH_LONG).show();
        try {
            if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
    //            Toast.makeText(this,"1",Toast.LENGTH_LONG).show();
                if (resultCode == RESULT_OK && fileUri != null) {
                    showImagePreview(fileUri.getPath());
                }
            } else if (requestCode == IMAGE_STORE) {
    //            Toast.makeText(this,"2",Toast.LENGTH_LONG).show();
    //                showImagePreview(FileUtil.getFilePath(this, data.getData()));

                FileUtil.getFilePath(this, data.getData());
                boolean isOri = data.getBooleanExtra("isOri",false);
                String path =  FileUtil.getFilePath(this, data.getData());

                File file = new File(path);
                if (file.exists()){
                    if (file.length() == 0) {
                        Toast.makeText(this, getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
                    }else {
                        if (file.length() > 1024 * 1024 * 10){
                            Toast.makeText(this, getString(R.string.chat_file_too_large),Toast.LENGTH_SHORT).show();
                        }else{
                            Message message = new ImageMessage(path,isOri);
                            presenter.sendMessage(message.getMessage());
                        }
                    }
                }else{
                    Toast.makeText(this, getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
                }








            } else if (requestCode == FILE_CODE) {
    //            Toast.makeText(this,"3",Toast.LENGTH_LONG).show();
    //            if (resultCode == RESULT_OK) {

    //            }
            } else if (requestCode == IMAGE_PREVIEW){

                if (resultCode == RESULT_OK) {
                    boolean isOri = data.getBooleanExtra("isOri",false);
                    String path = data.getStringExtra("path");
                    File file = new File(path);
                    if (file.exists()){
                        final BitmapFactory.Options options = new BitmapFactory.Options();
                        options.inJustDecodeBounds = true;
                        BitmapFactory.decodeFile(path, options);
                        if (file.length() == 0 && options.outWidth == 0) {
                            Toast.makeText(this, getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
                        }else {
                            if (file.length() > 1024 * 1024 * 10){
                                Toast.makeText(this, getString(R.string.chat_file_too_large),Toast.LENGTH_SHORT).show();
                            }else{
                                Message message = new ImageMessage(path,isOri);
                                presenter.sendMessage(message.getMessage());
                            }
                        }
                    }else{
                        Toast.makeText(this, getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
                    }
                }
            } else if (requestCode == VIDEO_RECORD) {
                if (resultCode == RESULT_OK) {
                    String videoPath = data.getStringExtra("videoPath");
                    String coverPath = data.getStringExtra("coverPath");
                    long duration = data.getLongExtra("duration", 0);
                    Message message = new UGCMessage(videoPath, coverPath, duration);
                    presenter.sendMessage(message.getMessage());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private void showImagePreview(String path){
        if (path == null) return;
        Intent intent = new Intent(this, ImagePreviewActivity.class);
        intent.putExtra("path", path);
        startActivityForResult(intent, IMAGE_PREVIEW);
    }

    private void sendFile(String path){
        if (path == null) return;
        File file = new File(path);
        if (file.exists()){
            if (file.length() > 1024 * 1024 * 10){
                Toast.makeText(this, getString(R.string.chat_file_too_large),Toast.LENGTH_SHORT).show();
            }else{
                Message message = new FileMessage(path);
                presenter.sendMessage(message.getMessage());
            }
        }else{
            Toast.makeText(this, getString(R.string.chat_file_not_exist),Toast.LENGTH_SHORT).show();
        }

    }

    //得到所有组团信息
    public void getMyTeamData() {
        KJHttp kjh = new KJHttp();
        KJStringParams params = new KJStringParams();
        String cmdPara = "{\"cmd\":\"9\",\"uid\":\"" + SysConfig.uid + "\",\"token\":\"" + SysConfig.token +"\",\"isleader\":\"0\",\"pageno\":\"1\",\"pagesize\":\"100\",\"keyword\":\"\"}";
        params.put("sendMsg", cmdPara);
        kjh.urlGet(SysConfig.ServerUrl, params, new StringCallBack() {
            @Override
            public void onSuccess(String t) {
                try {
                    JSONObject jsonObject = new JSONObject(t);
                    //Toast.makeText(mContext, t, Toast.LENGTH_LONG).show();
                    int result = Integer.parseInt(jsonObject.getString("result"));
                    if (result >= 1) {
                        ResTeamBean temp = new Gson().fromJson(t, ResTeamBean.class);
                        teamList = temp.getList();
                        transferTeamData();
                    } else {
                        Toast.makeText(RouteTeamActivity.this, jsonObject.get("retmsg").toString(), Toast.LENGTH_LONG).show();
                    }
                } catch (Exception ex) {
                    Toast.makeText(RouteTeamActivity.this,ex.toString(), Toast.LENGTH_LONG).show();
                }

            }

            @Override
            public void onFailure(Throwable t, int errorNo, String strMsg) {
                Toast.makeText(RouteTeamActivity.this, "网络异常，请稍后再试", Toast.LENGTH_LONG).show();
            }
        });


    }



    /*
     生成缩略图
     * 缩略图是将原图等比压缩，压缩后宽、高中较小的一个等于198像素
     * 详细信息参见文档
     */
    private Bitmap getThumb(String path){
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(path, options);
        int reqWidth, reqHeight, width=options.outWidth, height=options.outHeight;
        if (width > height){
            reqWidth = 198;
            reqHeight = (reqWidth * height)/width;
        }else{
            reqHeight = 198;
            reqWidth = (width * reqHeight)/height;
        }
        int inSampleSize = 1;
        if (height > reqHeight || width > reqWidth) {
            final int halfHeight = height / 2;
            final int halfWidth = width / 2;
            while ((halfHeight / inSampleSize) > reqHeight
                    && (halfWidth / inSampleSize) > reqWidth) {
                inSampleSize *= 2;
            }
        }
        try{
            options.inSampleSize = inSampleSize;
            options.inJustDecodeBounds = false;
            Matrix mat = new Matrix();
            Bitmap bitmap = BitmapFactory.decodeFile(path, options);
            ExifInterface ei =  new ExifInterface(path);
            int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
            switch(orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    mat.postRotate(90);
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    mat.postRotate(180);
                    break;
            }
            return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mat, true);
        }catch (IOException e){
            return null;
        }
    }

    //手机高版本样式
    private void initState() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            /* 透明导航栏 */
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }

    }

    private SystemBarTintManager tintManager;
    //手机高版本样式
    @TargetApi(19)
    private void initWindow() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            tintManager = new SystemBarTintManager(this);
            tintManager.setStatusBarTintColor(Color.TRANSPARENT);
            tintManager.setStatusBarTintEnabled(true);
        }
    }
    private void changeGridView() {
        // item宽度
        int itemWidth = dp2px(this, 75);
        // item之间的间隔
        int itemPaddingH =dp2px(this, 1);
        int size = tripData.list.get(0).teamMemberList.size()+1;
        // 计算GridView宽度
        int gridviewWidth = size * (itemWidth + itemPaddingH);

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                gridviewWidth, LinearLayout.LayoutParams.MATCH_PARENT);
        gvTeam.setLayoutParams(params);
        gvTeam.setColumnWidth(itemWidth);
        gvTeam.setHorizontalSpacing(itemPaddingH);
        gvTeam.setStretchMode(GridView.NO_STRETCH);
        gvTeam.setNumColumns(size);
    }

    /**
     *  得到的Rect就是根布局的可视区域，而rootView.bottom是其本应的底部坐标值，
      * 如果差值大于我们预设的值，就可以认定键盘弹起了。这个预设值是键盘的高度的最小值。
            * 这个rootView实际上就是DectorView，通过任意一个View再getRootView就能获得。
            */
    private boolean isKeyboardShown(View rootView) { final int softKeyboardHeight = 100;
        Rect r = new Rect();
        rootView.getWindowVisibleDisplayFrame(r);
        DisplayMetrics dm = rootView.getResources().getDisplayMetrics();
        int heightDiff = rootView.getBottom() - r.bottom;
        Log.e("hahah", heightDiff + "");
        return heightDiff > softKeyboardHeight * dm.density;
    }



    boolean haveChanged;
    int height = 0;
    private void setListenerToRootView() {

        View rootView = getWindow().getDecorView();
        rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override
        public void onGlobalLayout() {
            boolean isOpen = isKeyboardShown(etInput.getRootView());

            if(isOpen){ ObjectAnimator.ofFloat(etInput,"translationY",0,-height).setDuration(100).start();
                haveChanged=true;

            }else{ if(haveChanged) { ObjectAnimator.ofFloat(etInput, "translationY", -height, 0).setDuration(100).start();
            } } } });
    }




}





//{
//        "cmd": "30",
//        "result": "1",
//        "totalCount": "1",
//        "list": [{
//        "routePointList": [{
//        "routePointID": "106",
//        "routePointFlag": "1",
//        "routePointName": "绩溪县人民政府",
//        "longitude": "118.578519",
//        "latitude": "30.067533",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "107",
//        "routePointFlag": "1",
//        "routePointName": "石井",
//        "longitude": "118.638348",
//        "latitude": "30.08755",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "108",
//        "routePointFlag": "1",
//        "routePointName": "太极湖村风景区",
//        "longitude": "118.705044",
//        "latitude": "30.113503",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "109",
//        "routePointFlag": "1",
//        "routePointName": "黄茅培村",
//        "longitude": "118.786911",
//        "latitude": "30.136074",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "110",
//        "routePointFlag": "1",
//        "routePointName": "下雪堂",
//        "longitude": "118.813822",
//        "latitude": "30.133786",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "111",
//        "routePointFlag": "1",
//        "routePointName": "上雪堂",
//        "longitude": "118.822449",
//        "latitude": "30.134568",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "112",
//        "routePointFlag": "1",
//        "routePointName": "石柱下",
//        "longitude": "118.835444",
//        "latitude": "30.139258",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }, {
//        "routePointID": "113",
//        "routePointFlag": "1",
//        "routePointName": "浙基田",
//        "longitude": "118.861557",
//        "latitude": "30.150256",
//        "routeID": "1",
//        "addTime": "2019-01-13 15:54:19",
//        "routePointDetail": "",
//        "teamID": "0",
//        "sortID": "999"
//        }],
//        "teamInfo": [{
//        "teamID": "5",
//        "teamName": "测试组队2",
//        "userID": "294",
//        "addTime": "2018-12-10 19:10:11",
//        "teamPic": "route/20181206170604_940.jpg",
//        "startTime": "2018-02-10",
//        "endTime": "2018-11-10",
//        "routeID": "1",
//        "startFlag": "0",
//        "status": "1",
//        "equipment": "Sfsfsfsdf",
//        "activityStrength": "adadasddasdasdasd",
//        "activityFee": "100",
//        "remark": "Sfdsdfsdfds",
//        "disclaimer": "Fsdfsdfds",
//        "contact": "1834242324",
//        "scheduling": "Adsdadas",
//        "recommendFlag": "0",
//        "memberNumber": "0",
//        "nick": "测试领队2",
//        "routeName": "徽杭古道",
//        "routePic": "route/20190106090904_509.png",
//        "txGroupID": "Team_5"
//        }],
//        "teamMemberList": [],
//        "recordList": [{
//        "uid": "294",
//        "icon": "route\/20181206170604_940.jpg",
//        "remaindistance": "29.41",
//        "teamid": "5",
//        "speed": "0.0",
//        "altitude": "0.0",
//        "positioningerror": "550.0",
//        "longitude": "121.315816",
//        "latitude": "31.192749",
//        "walkeddistance": "0.0"
//        }, {
//        "uid": "292",
//        "icon": "icon\/icon.png",
//        "remaindistance": 259176.32776358645,
//        "teamid": "5",
//        "speed": -1,
//        "altitude": 7.664561748504639,
//        "positioningerror": 65,
//        "longitude": 121.28829264322917,
//        "latitude": 31.1847998046875,
//        "walkeddistance": 288318.0831675747
//        }]
//        }]
//        }
